package com.hqq.behaviour.chain;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * RequestHandler
 * 请求处理器
 * Created by heqianqian on 2017/6/16.
 */
public abstract class RequestHandler {

    private static final Logger logger = LoggerFactory.getLogger(RequestHandler.class);

    private RequestHandler next;

    public RequestHandler(RequestHandler handler) {
        this.next = handler;
    }

    public void handleRequest(Request req) {
        if (next != null) {
            next.handleRequest(req);
        }
    }

    protected void printHandling(Request req) {
        logger.info("{} handle \"{}\"", this, req);
    }

    @Override
    public abstract String toString();
}
